#include <stdio.h>
#include <stdlib.h>

#define kMaxSize 1000001
#define NIL -1

typedef int Position;
typedef struct StringNode *String;
struct StringNode {
    char data[kMaxSize]; /* 存储字符的数组 */
    int length; /* 字符串长度 */
};

String InitStr() {
    /* 初始化一个空的字符串 */
    String s;

    s = (String)malloc(sizeof(struct StringNode));
    s->length = 0;

    return s;
}

/* 算法4-11：朴素字符串匹配算法  PatternMatchBF(s, t) */
Position PatternMatchBF(String s, String t) {
    int n, m, i;
    Position p;

    n = s->length;
    m = t->length;
    for (p = 0; p <= (n - m); p++) {
        for (i = 0; i < m; i++) {
            if (s->data[p + i] != t->data[i]) {
                break; /* 不匹配则从下一个位置p开始 */
            }
        }
        if (i == m) { /* 匹配成功 */
            break;
        }
    }
    if (p > (n - m)) { /* 匹配不成功 */
        p = NIL;
    }
    return p;
}
/* 算法4-11 结束 */

String ReadString() {
    int i;
    String s;

    s = InitStr(); /* 创建空的字符串 */
    i = 0;
    s->data[i] = getchar();
    while (s->data[i] != '\n') {
        i++;
        s->data[i] = getchar();
    }
    s->data[i] = '\0'; /* 字符串结束符占1位 */
    s->length = i;
    return s;
}

int main(void) {
    String s, t;
    Position p;

    s = ReadString();
    t = ReadString();
    p = PatternMatchBF(s, t);
    if (p != NIL)
        printf("%s\n", s->data + p);
    else
        printf("匹配失败。\n");

    return 0;
}